<?php
	include_once("utils.php");
	main_content("main();");
	//include_once("UserIncludes/DbConfig.php");
	
	function main()
	{
	//echo "------->".$_SESSION['langId'];
	//=====================================================language=============================================
	
	if($_SESSION['langId']!="")
	{
		$langId=$_SESSION['langId'];
		//echo "+++++++".$langId;
	}
	else
	{
		$langId="1";
		//echo "-------".$langId;
	}
	
	
	//======================================================End============================================
	
	//==============NO OF FAVORITES========================================================================
	$sql="select s.adSiteUrl,s.adSiteId,adm.*,addet.adspaceType,fav.favId FROM ".FAVADSPACE." as fav,".SITEMASTER." as s,".ADSPSCEMASTER." as adm,".ADSPACEDETAILS." as addet where s.langId='".$langId."' and fav.userId='".$_SESSION[siteuserId]."' and fav.adspaceId=adm.adspaceId  and s.adsiteId=adm.adsiteId and addet.adspaceId=adm.adspaceId order by fav.addedOn desc";
	$query=mysql_query($sql);
	$numfav=mysql_num_rows($query);
	//echo $numfav;
	//======================================================End============================================
	//==========================================NO OF WEBSITE===========================================
	$sql1="select COUNT(*) FROM ".SITEMASTER." WHERE langId='".$langId."'AND siteuserId='".$_SESSION[siteuserId]."'AND status='Y'";
	//echo $sql1;
	$query=mysql_query($sql1);
	$fetch_count=mysql_fetch_array($query);
	//echo $fetch_count[0].'===';
	//------------------------------------------END-------------------------------------------------
	
	// ------------------------------------------NO OF AD SPACES START-------------------------------------
	$sql_adSpaces="select * from ".SITEMASTER." as SM ,".ADSPSCEMASTER." AM,".ADSPACEDETAILS." SD,".CATEGORIES." CA where SM.adsiteId=AM.adsiteId and AM.langId='".$langId."' and AM.UserId='".$_SESSION['siteuserId']."' and AM.adspaceId=SD.adspaceId and SM.adcategoryId=CA.adcategoryId and AM.status='Y'";
	$exe_adSpaces=mysql_query($sql_adSpaces);
	$total_active_adspaces=mysql_num_rows($exe_adSpaces);
	
	// ------------------------------------------ NO OF ADSPACES ENDS--------------------------------------
	
	// ---------------------------------------- No Of Records In Advertiser Statistics Starts--------------------------- 
	
	$sql_advertiser_statistics="SELECT * FROM advertise_master AM ,advertise_details AD , adspace_master ADM ,adspace_details ASD , adsite_master SM where AM.advertiseId= AD.advertiseId and AD.adspaceId=ADM.adspaceId and ADM.adspaceId=ASD.adspaceId and AD.adsiteId=SM.adsiteId and AM.siteuserId = '".$_SESSION['siteuserId']."' and AM.advertiseStatus = 'Y'";
	$exe_advertiser_statistics=mysql_query($sql_advertiser_statistics);
	$total_advertisement=mysql_num_rows($exe_advertiser_statistics);
	
	// ---------------------------------------- No Of Records In Advertiser Statistics Ends--------------------------- 
	
	########################################### No Of Records In Campaign Statistics Starts ################################
	
	$sql_records_campaign_statistics="select * from adcampaign where siteuserId = '".$_SESSION['siteuserId']."'";
	$exe_records_campaign_statistics=mysql_query($sql_records_campaign_statistics);
	$total_campaigns=mysql_num_rows($exe_records_campaign_statistics);
	
	################################# No Of Records In Campaign Statistics Ends #################################
	
	############################# no of expired advertisements starts#################
	$today=date("Y-m-d");
	
	$sql_expired_ads="SELECT * FROM advertise_master AM ,advertise_details AD , adspace_master ADM ,adspace_details ASD , adsite_master SM where AM.advertiseId= AD.advertiseId and AD.adspaceId=ADM.adspaceId and ADM.adspaceId=ASD.adspaceId and AD.adsiteId=SM.adsiteId and  AM.siteuserId = '".$_SESSION['siteuserId']."' and  AM.endDate < '".$today."'";
	
	$exe_expired_ads=mysql_query($sql_expired_ads);
	$num_expired_ads=mysql_num_rows($exe_expired_ads);
	
	############################# no of expired advertisements starts#################
	
	######################### no of direct active ads starts ######################
	$sql_direct_ads="SELECT * FROM advertise_master AM ,advertise_details AD , adspace_master ADM ,adspace_details ASD , adsite_master SM where AM.advertiseId= AD.advertiseId and AD.adspaceId=ADM.adspaceId and ADM.adspaceId=ASD.adspaceId and AD.adsiteId=SM.adsiteId and  AM.siteuserId = '".$_SESSION['siteuserId']."' and AD.networkId = 0 and AM.advertiseStatus = 'Y'";
	$exe_direct_ads=mysql_query($sql_direct_ads);
	$num_direct_ads=mysql_num_rows($exe_direct_ads);
	########################### no of direct active ads ends #######################
	
	######################### no of network active ads starts ######################
	$sql_network_ads="SELECT * FROM advertise_master AM ,advertise_details AD , adspace_master ADM ,adspace_details ASD , adsite_master SM where AM.advertiseId= AD.advertiseId and AD.adspaceId=ADM.adspaceId and ADM.adspaceId=ASD.adspaceId and AD.adsiteId=SM.adsiteId and  AM.siteuserId = '".$_SESSION['siteuserId']."' and AD.networkId > 0 and AM.advertiseStatus = 'Y'";
	$exe_network_ads=mysql_query($sql_network_ads);
	$num_network_ads=mysql_num_rows($exe_network_ads);
	########################### no of network active ads ends #######################
	?>
	
<table border="0" cellpadding="0" cellspacing="0" class="admob-Height" align="center">
	<tr>
	<td valign="top"><table border="0" align="center" cellpadding="0" cellspacing="0" class="admob-Height">
	<tr>
		<td width="244" valign="top"><?php include("left_pannel.php"); ?></td>
		<td width="14" valign="top">&nbsp;</td>
		<td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="admob-Height">
		<tr>
		<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td width="14"><img src="images/admob-BoxTopLeftCor.jpg" alt="" width="14" height="14" /></td>
			<td class="admob-BoxTopBg"><img src="images/spacer.gif" alt="" width="10" height="10" /></td>
			<td width="14"><img src="images/admob-BoxTopRightCor.jpg" alt="" width="14" height="14" /></td>
		</tr>
		</table></td>
		</tr>
		<tr>
		<td valign="top" class="admob-BoxMiddleBg"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="admob-Height">
		<tr>
			<td width="420" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="admob-Height">
			<tr>
			<td class="admob-SquareBoxTilteBg"><?php echo ADVERTISE_DASHBOARD; ?></td>
			</tr>
			<tr>
			<td class="admob-SquareBoxBorder"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="admob-Height">
			<tr>
				<td height="40"><a href="advertiser_statistics.php?mode=publisher_statistics&ad_status=expired&main=main" class="admob-biglink"><?php echo ALERT_EXPIRING_ADS;?></a> <span class="admob-redContent">(<?php echo $num_expired_ads; ?>)</span></td>
			</tr>
			<tr>
				<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
				<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td width="13"><img src="images/admob-InnerBoxTopLeft.jpg" alt="" width="13" height="30" /></td>
					<td class="admob-InnerBoxTopBg"><?php echo MANAGE_DIRECT_ADS;?></td>
					<td width="13"><img src="images/admob-InnerBoxTopRight.jpg" alt="" width="13" height="30" /></td>
				</tr>
				</table></td>
				</tr>
				<tr>
				<td class="admob-InnerBoxBotomBorder"><table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
				<tr>
					<td width="30" height="25"><img src="images/admob-circleIcon.jpg" alt="" width="20" height="16" /></td>
					<td><a href="buy_spaceNew.php" class="admob-link"><?php echo BUY_DIRECT_ADS; ?></a></td>
				</tr>
				<tr>
					<td height="25"><img src="images/admob-StarIcon.jpg" alt="" width="18" height="19" /></td>
					<td><a href="favList.php" class="admob-link"><?php echo MY_FAVOURITS;?> <span class="admob-redContent"> <?php echo $numfav;?></span></a></td>
				</tr>
				<tr>
					<td height="25"><img src="images/admob-CartIcon.jpg" alt="" width="18" height="20" /></td>
					<td><a href="advertiser_statistics.php?mode=publisher_statistics&purchase_type=direct&main1=main1" class="admob-link"><?php echo DIRECT_ADS_STATES;?> <span class="admob-redContent">(<?php echo $num_direct_ads; ?> <?php echo ACTIVE; ?>)</span></a> </td>
				</tr>
				<tr>
					<td height="25"><img src="images/admob-padIcon.jpg" alt="" width="20" height="19" /></td>
					<td><a href="user-purchase-history.php" class="admob-link"><?php echo AD_PURCHASE; ?></a></td>
				</tr>
				</table></td>
				</tr>
				</table></td>
			</tr>
			<tr>
				<td class="admob-Height">&nbsp;</td>
			</tr>
			<tr>
				<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
				<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
					<td width="13"><img src="images/admob-InnerBoxTopLeft.jpg" alt="" width="13" height="30" /></td>
					<td class="admob-InnerBoxTopBg"><?php echo MANAGE_NETWORK_ADS;?></td>
					<td width="13"><img src="images/admob-InnerBoxTopRight.jpg" alt="" width="13" height="30" /></td>
					</tr>
				</table></td>
				</tr>
				<tr>
				<td class="admob-InnerBoxBotomBorder"><table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
					<tr>
					<td width="30" height="33"><img src="images/admob-circleIcon.jpg" alt="" width="20" height="16" /></td>
					<td><a href="buyNetworkAds.php" class="admob-link"><?php echo BUY_NETWORK_ADS ;?></a><br /><a href="buying_campaign_manager.php" class="admob-link"><?php echo RUN_CAMPAIGN;?></a></td>
					</tr>
	
					<tr>
					<td height="33"><img src="images/admob-CartIcon.jpg" alt="" width="18" height="20" /></td>
					<td><a href="advertiser_statistics.php?mode=publisher_statistics&purchase_type=network&main1=main1" class="admob-link"><?php echo NETWORK_ADS_STARTS;?><span class="admob-redContent"> (<?php echo $num_network_ads; ?> <?php echo ACTIVE; ?>)</span></a><br /><a href="campaign_statistics.php" class="admob-link"><?php echo CAMPAIN_STATES;?><span class="admob-redContent"> <?php echo $total_campaigns; ?></span></a></td>
					</tr>
					<tr>
					<td height="33"><img src="images/admob-padIcon.jpg" alt="" width="20" height="19" /></td>
					<td><a href="user-purchase-history.php" class="admob-link"><?php echo AD_PURCHASE; ?></a></td>
					</tr>
				</table></td>
				</tr>
				</table></td>
			</tr>
			</table></td>
			</tr>
			</table></td>
			<td width="22" valign="top">&nbsp;</td>
			<td width="420" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="admob-Height">
			<tr>
			<td class="admob-SquareBoxTilteBg"><?php echo PUBLISHER_DASHBOARD;?></td>
			</tr>
			<tr>
			<td class="admob-SquareBoxBorder"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="admob-Height">
			<tr>
				<td height="40"><a href="accept_order.php" class="admob-biglink"><?php echo ALERTS_ADS_TO_APPROVED;?></a></td>
			</tr>
			<tr>
				<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
				<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
					<td width="13"><img src="images/admob-InnerBoxTopLeft.jpg" alt="" width="13" height="30" /></td>
					<td class="admob-InnerBoxTopBg"><a href="payment-history.php" class="admob-leftlink"><?php echo VIEW_EARNING; ?></a></td>
					<td width="13"><img src="images/admob-InnerBoxTopRight.jpg" alt="" width="13" height="30" /></td>
					</tr>
				</table></td>
				</tr>
				<tr>
				<td class="admob-InnerBoxBotomBorder"><table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
					<tr>
					<td width="30" height="33"><img src="images/admob-circleIcon.jpg" alt="" width="20" height="16" /></td>
					<td><a href="payment-history.php" class="admob-link"><?php echo EARNING_PAYMENTS; ?></a></td>
					</tr>
					<tr>
					<td height="33"><img src="images/admob-StarIcon.jpg" alt="" width="18" height="19" /></td>
					<td><a href="pub_statistics.php" class="admob-link"><?php echo PUBLISHER_STATES ?></a></td>
					</tr>
	
					<tr>
					<td height="33"><img src="images/admob-padIcon.jpg" alt="" width="20" height="19" /></td>
					<td><a href="sales_history.php" class="admob-link"><?php echo SALES_HISTORY ;?></a></td>
					</tr>
				</table></td>
				</tr>
				</table></td>
			</tr>
			<tr>
				<td class="admob-Height">&nbsp;</td>
			</tr>
			<tr>
				<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
				<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
					<td width="13"><img src="images/admob-InnerBoxTopLeft.jpg" alt="" width="13" height="30" /></td>
					<td class="admob-InnerBoxTopBg"><a href="all_adspaces.php" class="admob-leftlink"><?php echo MANAGE_AD_SPACE_SITES;?></a></td>
					<td width="13"><img src="images/admob-InnerBoxTopRight.jpg" alt="" width="13" height="30" /></td>
					</tr>
				</table></td>
				</tr>
				<tr>
				<td class="admob-InnerBoxBotomBorder"><table width="94%" border="0" align="center" cellpadding="0" cellspacing="0">
					<tr>
					<td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
					<tr>
					<td width="30" height="33"><img src="images/admob-padIcon.jpg" alt="" width="20" height="19" /></td>
					<td><a href="all_websites.php" class="admob-link"><?php echo EDIT_WEBSITE; ?></a><br />
						<span class="admob-redContent">(<?php echo $fetch_count[0];?> Active)</span></td>
					</tr>
					<tr>
					<td height="33">&nbsp;</td>
					<td>&nbsp;</td>
					</tr>
					<tr>
					<td height="33"><img src="images/admob-CartIcon.jpg" alt="" width="18" height="20" /></td>
					<td><a href="sell_website_add.php" class="admob-link"><?php echo AD_WEBSITE;?></a></td>
					</tr>
					</table></td>
					<td width="30">&nbsp;</td>
					<td><table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
					<tr>
					<td width="30" height="33"><img src="images/admob-circleIcon.jpg" alt="" width="20" height="16" /></td>
					<td><a href="all_adspaces.php" class="admob-link"><?php echo EDIT_AD_SPACE;?></a><br />
										<span class="admob-redContent">(<?php echo $total_active_adspaces; ?> <?php echo ACTIVE;?>)</span></td>
					</tr>
					<tr>
					<td height="33">&nbsp;</td>
					<td>&nbsp;</td>
					</tr>
					<tr>
					<td height="33"><img src="images/admob-CartIcon.jpg" alt="" width="18" height="20" /></td>
					<td><a href="customize_ad.php" class="admob-link"><?php echo ADD_AD_SPACE;?> </a></td>
					</tr>
					</table></td>
					</tr>
				</table></td>
				</tr>
				</table></td>
			</tr>
			</table></td>
			</tr>
			</table></td>
		</tr>
		</table></td>
		</tr>
		<tr>
		<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td width="14"><img src="images/admob-BoxBottomLeftCor.jpg" alt="" width="14" height="14" /></td>
			<td class="admob-BoxBottomBg"><img src="images/spacer.gif" alt="" width="10" height="10" /></td>
			<td width="14"><img src="images/admob-BoxBottomRightCor.jpg" alt="" width="14" height="14" /></td>
		</tr>
		</table></td>
		</tr>
		</table></td>
	</tr>
	</table></td>
	</tr>
</table>
<?php
}
?>
	
